{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt ### fig:class_world1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "class World:         \n",
    "    def __init__(self):\n",
    "        self.objects = []             # ここにロボットなどのオブジェクトを登録\n",
    "        \n",
    "    def append(self,obj):             # オブジェクトを登録するための関数\n",
    "        self.objects.append(obj)\n",
    "    \n",
    "    def draw(self):\n",
    "        fig = plt.figure(figsize=(8,8))                # 8x8 inchの図を準備\n",
    "        ax = fig.add_subplot(111)                      # サブプロットを準備\n",
    "        ax.set_aspect('equal')                         # 縦横比を座標の値と一致させる\n",
    "        ax.set_xlim(-5,5)                              # X軸を-5m x 5mの範囲で描画\n",
    "        ax.set_ylim(-5,5)                              # Y軸も同様に\n",
    "        ax.set_xlabel(\"X\",fontsize=20)                 # X軸にラベルを表示\n",
    "        ax.set_ylabel(\"Y\",fontsize=20)                 # 同じくY軸に\n",
    "        \n",
    "        for obj in self.objects: obj.draw(ax)           # appendした物体を次々に描画\n",
    "            \n",
    "        plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAfEAAAHsCAYAAADCepQ4AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAEH1JREFUeJzt3WuIpQd9x/Hfv1mhF1OkZK00m3QD2pbUhNqO6SUvbFVstKl50RbURrC2XbAKCaTES9q+8E2htmqpVtlqL5KACCopVquRKrYUxc1lU5OoBPEWFCeUorSiXfz3xYywTXd3NunsPM9/9vOBgT3nPOz58RDy3efMzDnV3QEA5vmepQcAA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LxIFTqqpLsxXoytbvg3/hNMf9TpK/SnJHkl9u/1OBPSPiADCU74kDwFAiDgBDiTgADCXiADCUiAPAUCIOAEOJOAAMJeIAMJSIA8BQ/wNvgqN/PEPTUQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 576x576 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "world = World()     ### fig:class_world3\n",
    "world.draw()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
